class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :openid_authenticatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :identity_url
  # attr_accessible :title, :body

  has_one  :test, :class_name=>"TestToken", :dependent=>:destroy

  has_many :consumer_tokens , :dependent=>:destroy
  
  def self.build_from_identity_url(identity_url)
    User.new(:identity_url => identity_url)
  end

  def self.create_from_identity_url(identity_url)
    self.create(:identity_url => identity_url)
  end

  def self.openid_required_fields
    ["fullname", "email"]
  end

  def self.openid_optional_fields
    ["gender", "nickname"]
  end

end
